
" 按 gf 打开当前行所在的文件, 假设当前行为 "import aaa.bbb.ccc;" 则会打开 "aaa/bbb/ccc.as"
function! GoFile()

	let line = getline('.')

	" import aaa.bbb.ccc
	if( stridx(line, "import" ) >= 0 )
		let line = substitute( line, "^.*import\\s\\+\\([a-zA-Z0-9.]\\+\\).*$", "\\1", "" )
	" useing aaa.bbb.ccc
	elseif( stridx(line, "using" ) >= 0 )
		let line = substitute( line, "^.*using\\s\\+\\([a-zA-Z0-9.]\\+\\).*$", "\\1", "" )
	" \<word\>
	else
		normal yiw
		let line = @0
		exec "ed **/" . line
		return
	endif

	let line = substitute( line, "\\.", "/", "g")
	let line = line . ".as"
	if filereadable( line )
		exec "ed " . line
	else
		echo "file not exist: \"" . line . "\""
	endif
endfunction


noremap gf :exec GoFile()<cr>
